package com.ngmaster.socket.message;

import com.ngmaster.socket.ProtocolMessage;

import java.util.Arrays;

/**
 * 模式切换：
 * 接收应答一致：
 * 0x00（流量模式）;0x01（时长模式）
 */
public class SwitchBillModelMessage extends ProtocolMessage {

    /** 标记0x00 */
    private byte model;

    /** 转换系数；N升/天 */
    private short scale;

    public byte getModel() {
        return model;
    }

    public void setModel(byte model) {
        this.model = model;
    }

    public short getScale() {
        return scale;
    }

    public void setScale(short scale) {
        this.scale = scale;
    }

    @Override
    public void onSerial() {
        this.byteArray.writeByte(this.model);
        this.byteArray.writeShort(this.scale);
    }

    @Override
    public void onDeserialize() {
        this.model = this.byteArray.readByte();
        this.scale = this.byteArray.readShort();
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("SwitchBillModelMessage{");
        sb.append("model=").append(model);
        sb.append(", scale=").append(scale);
        sb.append(", imeiBytes=").append(Arrays.toString(imeiBytes));
        sb.append(", imei='").append(imei).append('\'');
        sb.append(", cmd=").append(cmd);
        sb.append(", dataLength=").append(dataLength);
        sb.append(", crc=").append(crc);
        sb.append(", crcHex='").append(crcHex).append('\'');
        sb.append(", byteArray=").append(byteArray);
        sb.append('}');
        return sb.toString();
    }
}
